<?php

namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;

class ListController extends HomeBaseController
{
    public function index()
    {
        $id                  = $this->request->param('id', 0, 'intval');
        $portalCategoryModel = new PortalCategoryModel();

        $category = $portalCategoryModel->where('id', $id)->where('status', 1)->find();
       
        $this->assign('category', $category);

        $listTpl = empty($category['list_tpl']) ? 'list' : $category['list_tpl'];

        return $this->fetch('/' . $listTpl);
    }
        /*面包屑导航*/
        function get_bread_nav($module,$trem_id){
             $arr['href']['action']=$module;
             $arr['href']['param']['id']=$trem_id;
             $nav=M('nav');
             $rs=$nav->select();
             foreach($rs as $k=>$v){
                 $rs[$k]['href']=unserialize(stripslashes($v['href']));
             }
             if($module!='home'){
                 foreach($rs as $k=>$v){
                    if($v['href']==$arr['href']){
                        $a=$v;
                    }
                 }
                $bread_path=$a['path'];
                $arr_path=explode("-",$bread_path);
                $str_path=" <li><a href='/' class='icon-home'> 首页</a></li>";
             
                for($i=1;$i<count($arr_path);$i++){
                    $breadtitle=$nav->where("id=$arr_path[$i] and status=1 ")->find();
                    $breadtitle['href']=unserialize($breadtitle['href']);
                    $href=leuu($breadtitle['href']['action'],array('id'=>$breadtitle['href']['param']['id']));
                    $str_path.="<li><a href=$href>".$breadtitle['label']."</a></li>";
                }
            }else{
                  $str_path="<li><a href='/' class='icon-home'> 首页</a></li>";
            }
             return  $str_path;
        }

}
